#!/bin/bash
set -e
. tests/lib
. $troot/lib-baredebian

t-restrict x-dgit-skip-suite,bullseye
t-restrict x-dgit-skip-suite,buster
t-dependencies T2U quilt

t-t2u-settings
t-debpolicy

t-setup-import baredebian

cd $p

baredebian-test-vars
t-t2u-setup-repo

baredebian-test-minimum
baredebian-test-core-prepush


sed -i '15icorruption' debian/patches/0002-Edit-the-.c-file.patch
git add debian/patches/0002-Edit-the-.c-file.patch
git commit -m"corrupt a quilt patch to test the patches-nonapplicable check"

tagname=test-dummy/$v

t-expect-fail "'git apply' failed to apply patch 0002-Edit-the-.c-file.patch ('patches-nonapplicable' check)" \
t-t2u-test --baredebian

git reset --hard HEAD~1

t-t2u-test --baredebian
t-t2u-succeeded

git branch split.p dgit/dgit/sid # we didn't generate this here

baredebian-test-core-postpush

t-t2u-gittarxz-unpack
t-dgit -wn --quilt=$quiltmode --dgit-view-save=split.t quilt-fixup
t-t2u-gittarxz-reproduced

t-ok
